package com.github.zzay.user.feign;

import com.github.zzay.common.core.constant.ServiceConstant;
import com.github.zzay.common.core.model.ResponseBean;
import com.github.zzay.user.dto.UserDto;
import com.github.zzay.user.feign.factory.UserServiceClientFallbackFactory;
import com.github.zzay.common.feign.config.OpenFeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author zzay
 * @className UserServiceClient
 * @description User Service Client
 * @create 2022/06/16 15:12
 */
@FeignClient(value = ServiceConstant.USER_SERVICE,
        configuration = OpenFeignConfig.class,
        fallback = UserServiceClientFallbackFactory.class)
public interface UserServiceClient {

    /**
     * 获取当前用户的信息
     *
     * @return 包含用户详细信息的响应Bean
     */
    @GetMapping("/user/info")
    ResponseBean info();

    /**
     * 根据用户名获取用户详细信息
     *
     * @param identifier identifier
     * @return 包含用户详细信息的响应 Bean
     */
    @GetMapping("/user/getByIdentifier")
    ResponseBean getUserByIdentifier(@RequestBody String identifier);

    /**
     * 根据用户 id 获取用户
     *
     * @param ids ids
     * @return 包含用户详细信息列表的响应 Bean
     */
    @RequestMapping(value = "/user/getById", method = RequestMethod.POST)
    ResponseBean getUserById(@RequestBody Long[] ids);

    /**
     * 注册用户
     *
     * @param userDto userDto
     * @return 包含请求处理结果的响应 Bean
     */
    @PostMapping("/user/register")
    ResponseBean registerUser(@RequestBody UserDto userDto);

    /**
     * 查询用户数量
     *
     * @param userDto userDto
     * @return 包含用户数量的响应 Bean
     */
    @RequestMapping(value = "/user/getCount", method = RequestMethod.POST)
    ResponseBean getUserCount(@RequestBody UserDto userDto);

}
